<template>
	<view class="mutual-assistance">
		<view class="classification-top" style="position: sticky;top: 80rpx;">
			<zb-dropdown-menu style="width: 100%;">
				<zb-dropdown-item name="first" :options="option" v-model="value1" @change="change1"></zb-dropdown-item>
				<zb-dropdown-item name="two" :options="option1" v-model="value2" @change="change2"></zb-dropdown-item>
				<zb-dropdown-item name="three" :options="option2" v-model="value3" @change="change3"></zb-dropdown-item>
			</zb-dropdown-menu>
		</view>
		<view class="nveiling-box">
			<nveilingCard v-for="(item,inedx) in nveilingInf" :title="item.title" :unveilingText="item.unveilingText"
				:unveilingAddress="item.unveilingAddress" :enterpriceUrl="item.enterpriceUrl"
				:enterpriceTitle="item.enterpriceTitle" :describeList="item.describeList" :showFlag="item.showFlag"
				@getDetailData="getDetail" :interestFlag="interestFlag"></nveilingCard>
		</view>
    	<none-data  v-if="nveilingInf.length===0 && isLoading"/>
	</view>
</template>

<script setup>
	// import comment from "./components/comment.vue"
	import nveilingCard from "./componts/nveiling-card.vue"
	import { onLoad	,onNavigationBarSearchInputConfirmed} from '@dcloudio/uni-app'
	import zbDropdownItem from "@/uni_modules/zb-dropdown-menu/components/zb-dropdown-item/zb-dropdown-item.vue"
	import zbDropdownMenu from "@/uni_modules/zb-dropdown-menu/components/zb-dropdown-menu/zb-dropdown-menu.vue"
	import { getXhBGroupByList } from "@/api/mutual-assistance";
	import {
		onMounted,
		ref
	} from "vue";
	import {
		onNavigationBarButtonTap
	} from '@dcloudio/uni-app'
	const requestType=ref("")
	const interestFlag = ref(true)
	const value1 = ref(0)
	const value3=ref('a')
	const value2 = ref(0)
	const option = ref([{
			text: "其他类",
			value: 0
		},
		{
			text: "开发类",
			value: 1
		},
		{
			text: "设计类",
			value: 2
		},
		{
			text: "营销类",
			value: 3
		},
		{
			text: "咨询类",
			value: 4
		},
	]);
	const option1 = ref([{
			text: "待揭榜",
			value: 0
		},
		{
			text: "已揭榜",
			value: 1
		}
	]);
	const option2 = ref([{
			text: "默认排序",
			value: "a"
		},
		{
			text: "揭榜人数",
			value: "b"
		},
		{
			text: "发布时间",
			value: "c"
		},
	]);
	const nveilingInf = ref([])
	const isLoading = ref(false)

	function getDetail(data) {
	}
	function change1(data) {
		getdata(data.text)
	}
	function change2(data){
	nveilingInf.value=[]
	isLoading.value = false
			getXhBGroupByList({
		    "size": 20,
		    "jbStatus":data.value,
		    "page":1
		}).then((res)=>{
			console.log(res.data,'........')
			isLoading.value = true
			let result=res.data.records
			result.map((o)=>{
				if(o.xhbPublishPersonInfoVoList){nveilingInf.value.push({
					showFlag: o.requestType,
					publishPersonId:o.id,
					title: o.title,
					unveilingText: o.description,
					unveilingAddress: o.location,
					enterpriceUrl: o.avatar,
					imageUrl: o.avatar,
					enterpriceTitle:o.xhbPublishPersonInfoVoList? o.xhbPublishPersonInfoVoList[0].publishName:'',
					describeList:  o.xhbPublishPersonInfoVoList.map((item)=>{
						return item.honorName
					})
				})}else{
					nveilingInf.value.push({
						showFlag: o.requestType,
						publishPersonId:o.id,
						title: o.title,
						unveilingText: o.description,
						unveilingAddress: o.location,
						enterpriceUrl: o.avatar,
						imageUrl: o.avatar,
						enterpriceTitle:o.xhbPublishPersonInfoVoList? o.xhbPublishPersonInfoVoList[0].publishName:'',
						describeList:''
					})
				}

			})

		})
	}
	function change3(data){
		console.log(data.text)
		let obj={"size": 20,
		    "jbStatus":1,
		    "page":1}
		if(data.text=='揭榜人数'){
			obj.useadNumberOrderType=0
		}else{
			obj.publishTimeOrderType=0
		}

		getXhBGroupByList(
			obj

		).then((res)=>{
			console.log(res.data,'........')
			isLoading.value = true
			let result=res.data.records
			result.map((o)=>{
				if(o.xhbPublishPersonInfoVoList){nveilingInf.value.push({
					showFlag: o.requestType,
					publishPersonId:o.id,
					title: o.title,
					unveilingText: o.description,
					unveilingAddress: o.location,
					enterpriceUrl: o.avatar,
					imageUrl: o.avatar,
					enterpriceTitle:o.xhbPublishPersonInfoVoList? o.xhbPublishPersonInfoVoList[0].publishName:'',
					describeList:  o.xhbPublishPersonInfoVoList.map((item)=>{
						return item.honorName
					})
				})}else{
					nveilingInf.value.push({
						showFlag: o.requestType,
						publishPersonId:o.id,
						title: o.title,
						unveilingText: o.description,
						unveilingAddress: o.location,
						enterpriceUrl: o.avatar,
						imageUrl: o.avatar,
						enterpriceTitle:o.xhbPublishPersonInfoVoList? o.xhbPublishPersonInfoVoList[0].publishName:'',
						describeList:''
					})
				}

			})

		})
	}
	function getdata(data){
	nveilingInf.value=[]
	isLoading.value = false
			getXhBGroupByList({
		  "requestType": data,
		    "size": 20,
		    "jbStatus":2,
		    "page":1
		}).then((res)=>{
			console.log(res.data,'........')

			let result=res.data.records
			isLoading.value = true
			result.map((o)=>{
				if(o.xhbPublishPersonInfoVoList){nveilingInf.value.push({
					showFlag: o.requestType,
					publishPersonId:o.id,
					title: o.title,
					unveilingText: o.description,
					unveilingAddress: o.location,
					enterpriceUrl: o.avatar,
					imageUrl: o.avatar,
					enterpriceTitle:o.xhbPublishPersonInfoVoList? o.xhbPublishPersonInfoVoList[0].publishName:'',
					describeList:  o.xhbPublishPersonInfoVoList.map((item)=>{
						return item.honorName
					})
				})}else{
					nveilingInf.value.push({
						showFlag: o.requestType,
						publishPersonId:o.id,
						title: o.title,
						unveilingText: o.description,
						unveilingAddress: o.location,
						enterpriceUrl: o.avatar,
						imageUrl: o.avatar,
						enterpriceTitle:o.xhbPublishPersonInfoVoList? o.xhbPublishPersonInfoVoList[0].publishName:'',
						describeList:''
					})
				}

			})

		})
	}
	onNavigationBarButtonTap(() => {
		uni.navigateTo({
			url: "/package_mutual_assistance/pages/mutual-assistance/release-requirements"
		})
	})
	onMounted(()=>{
		console.log("inlai",requestType.value)
	option.value.forEach((o)=>{
		if(o.text==requestType.value){
			value1.value=o.value
		}
	})
	getdata(requestType.value)
		})
	onLoad((option)=>{
		requestType.value=option.type

	})
	onNavigationBarSearchInputConfirmed((e) => {
		getdata(e.text)

	})
</script>

<style lang="less" scoped>
	.mutual-assistance {
		.nveiling-box {
			padding-left: 40rpx;
			background-color: #FFFFFF;
		}

		.classification-top {
			margin: 20rpx 0 0 0;

			.filter-wrappe {
				.uni-page-body {
					color: #272636;
				}
			}
		}


	}
</style>
